//
//  UITableView+backImageView.m
//  ContinueEducation
//
//  Created by 迟建国 on 2018/9/26.
//  Copyright © 2018年 CE. All rights reserved.
//

#import "UITableView+backImageView.h"

@implementation UITableView (backImageView)

#pragma 发现课程

-(void)setNoDataImage:(BOOL)noDataImage
{
    self.tipView.hidden = noDataImage;
}

-(BOOL)noDataImage
{
    return self.tipView.hidden;
}
- (UIView *)tipView
{
    UIView *tipView = objc_getAssociatedObject(self, "TipView");
    if (!tipView) {
        tipView = [[UIView alloc] initWithFrame:self.bounds];
        [self addSubview:tipView];
        
        tipView.backgroundColor = [UIColor clearColor];
        
        UIImageView *  imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 120, 85)];
        //        imageView.contentMode = UIViewContentModeCenter;
        imageView.center = CGPointMake(SCREEN_H/2, self.ce_height/2 - 50);

        imageView.image = [UIImage imageNamed:@"no_data_img"];
        
        [tipView addSubview:imageView];
        
        UILabel *noDataL = [[UILabel alloc] initWithFrame:CGRectMake(50, CGRectGetMaxY(imageView.frame) + 12, SCREEN_H - 100, 20)];
        noDataL.text = @"暂无数据";
        noDataL.textColor = rgbHex(0x999999,1);
        noDataL.textAlignment = NSTextAlignmentCenter;
        noDataL.font = [UIFont systemFontOfSize:14];
        [tipView addSubview:noDataL];
        
        
        objc_setAssociatedObject(self, "TipView", tipView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        
    }
    return tipView;
}
- (void)findCourse{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"OPENPLAINNOTIFICATION" object:nil];
}

#pragma 学习记录无数据
-(void)setNoNomalDataImage:(BOOL)noNomalDataImage
{
    self.backGroundView.hidden = noNomalDataImage;
}

-(BOOL)noNomalDataImage
{
    return self.backGroundView.hidden;
}
- (UIView *)backGroundView
{
    UIView *backGroundView = objc_getAssociatedObject(self, "backGroundView");
    if (!backGroundView) {
        backGroundView = [[UIView alloc] initWithFrame:self.bounds];
        [self addSubview:backGroundView];
        
        backGroundView.backgroundColor = [UIColor clearColor];
        
        UIImageView *  imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 140, 160)];
        //        imageView.contentMode = UIViewContentModeCenter;
        imageView.center = CGPointMake(SCREEN_W/2, self.ce_height/2 - 70);

        imageView.image = [UIImage imageNamed:@"commom_kongyemian"];
        
        [backGroundView addSubview:imageView];
        
//        UILabel *noDataL = [[UILabel alloc] initWithFrame:CGRectMake(50, CGRectGetMaxY(imageView.frame) + kRealValueHeight(35), SCREEN_WIDTH - 100, 20)];
//        noDataL.text = @"无学习记录";
//        noDataL.textAlignment = NSTextAlignmentCenter;
//        noDataL.font = kFont(14);
//        [backGroundView addSubview:noDataL];
        
        objc_setAssociatedObject(self, "backGroundView", backGroundView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        
    }
    return backGroundView;
}

@end
